<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
namespace bdd;

error_reporting(E_ALL);

define("GAME", true);

include '../api/master.php';

$tablesQuery = "SHOW TABLES";

$conn = Connection::getConnection();

foreach  ($conn->ExecQuery($tablesQuery) as $table) {
    $tbl = $table[0];
    echo "<h1>".$tbl."</h1><pre>";

    $filename = ROOT . 'ini/bdd/'.$tbl.'.ini';

    if (!$handle = fopen($filename, 'w')) {
         echo "Impossible d'ouvrir le fichier ($filename)";
         exit;
    }

    foreach  ($conn->ExecQuery("SHOW FULL COLUMNS FROM ". $tbl) as $column) {
        if(isset($column[5])) {
            if(is_numeric($column[5])) {
                $line = $column[0] . " = " . $column[5] . " \n";
            }
            else
            {
                $line = $column[0] . " = \"" . $column[5] . "\" \n";
            }

            if (fwrite($handle, $line) === FALSE) {
                echo "Impossible d'écrire dans le fichier ($filename)";
                exit;
            }
        }
    }

    fclose($handle);

    echo "</pre>";
}


    /*foreach  ($conn->ExecQuery($tablesQuery) as $table) {
        print $row[0] . " = " . $row[1] . "
";
    }*/
?>
